﻿#define _CRT_SECURE_NO_WARNINGS 1
#include "SList.h"
//void SListTest()
//{

	//PrintStudent方法的测试
	//StudentNode* node1 = (StudentNode*)malloc(sizeof(StudentNode));
	//strcpy(node1->name, "朱钱");
	//strcpy(node1->id, "2025010101");
	//strcpy(node1->college, "计算机科学与技术学院");
	//strcpy(node1->major, "计算机科学与技术");
	//strcpy(node1->class_name, "计科2301班");
	//strcpy(node1->gender, "男");
	//node1->age = 20;

	//StudentNode* node2 = (StudentNode*)malloc(sizeof(StudentNode));
	//strcpy(node2->name, "韩子萱");
	//strcpy(node2->id, "2025010101");
	//strcpy(node2->college, "计算机科学与技术学院");
	//strcpy(node2->major, "计算机科学与技术");
	//strcpy(node2->class_name, "计科2301班");
	//strcpy(node2->gender, "男");
	//node2->age = 20;
	//
	////将node1和node2链接起来
	//node1->next = node2;
	//node2->next = NULL;
	//PrintStudent(node1);

	//头插节点的测试
//	StudentNode* plist = NULL;
//	SLTPushFrontInteractive(&plist);
//	SLTPushFrontInteractive(&plist);
//	PrintStudent(plist);
//	
//	//测试查找方法
//	printf("请输入您想要查询人的姓名：");
//	char name[NAMEMAX];
//	scanf("%s", name);
//	StudentNode* find = STLFindByName(plist, name);
//	
//
//	//测试删除方法
//	STLDeleteNode(&plist, find);
//	PrintStudent(plist);
//}
//
//int main()
//{
//	SListTest();
//	return 0;
//}






void menu() {
    printf("*****************学生管理系统*******************\n");
    printf("*******1.增加学生  2.删除学生（按姓名）*********\n");
    printf("*******3.查找学生  4.打印所有学生***************\n");
    printf("*******************0.退出***********************\n");
}

/**
 * 主函数
 */
int main() {
    int op = -1;
    StudentNode* plist = NULL;  // 链表头指针

    do {
        menu();
        printf("请输入您的操作:\n");
        scanf("%d", &op);

        switch (op) {
        case 1:
            SLTPushFrontInteractive(&plist);
            break;
        case 2: {
            char name[NAMEMAX];
            printf("请输入要删除的学生姓名: ");
            scanf("%s", name);
            StudentNode* toDelete = STLFindByName(plist, name);
            if (toDelete) {
                STLDeleteNode(&plist, toDelete);
            }
            else {
                printf(" 未找到该学生！\n");
            }
            break;
        }
        case 3: {
            char name[NAMEMAX];
            printf("请输入要查找的学生姓名: ");
            scanf("%s", name);
            StudentNode* find = STLFindByName(plist, name);
            if (find) {
                printf("该学生存在\n");
            }
            else {
                printf("未找到该学生！\n");
            }
            break;
        }
        case 4:
            PrintStudent(plist);  // 或 SLTPrint(plist)
            break;
        case 0:
            printf("退出学生管理系统！\n");
            break;
        default:
            printf("请选择正确的操作！\n");
            break;
        }
    } while (op != 0);

    return 0;
}
